<% layout("/WEB-INF/view/console/skins/skin_2/layout.html", {}) {
%>
<div class="row">
    <div class="col-md-12">
        <div class="widget-container fluid-height clearfix">
            <div class="widget-content padded clearfix">
                <div class='row'>
                    <div class='col-md-12'>
                        <form name="boMessage_form" id="boMessage_form" class='form-inline'>
                            <div class='form-group col-md-3' style='margin-top: 10px;'>
 <label title='消息类型' >消息类型：</label>
 <select class="form-control" id="messageType" name="messageType">
 <option  value="">请选择...</option>
 	<option  value="1">官方推送</option>
 </select>
 </div>
 <div class='form-group col-md-3' style='margin-top: 10px;'>
 <label title='消息标题'  >消息标题：</label>
 <input  onkeyup='boMessageConsoleGrid.enterToQuery(event);' type='text' class='form-control' id='messageTitle' name='messageTitle' placeholder=''>
 </div>
 
                        </form>
                    </div>
                </div>
                <div class='row'>
                    <div align="center">
                        <button type='button' class='btn btn-default' id='boMessageQuerySearch'>查询</button>
                        <button type='button' class='btn btn-default' id='boMessageReset'>重置</button>
                    </div>
                </div>
                 <div id="boMessageToolbar" class="btn-group">
                              <button type="button" class="btn btn-default" onclick="consoleOpenWindow('boMessage','${ctxPath}/console/bo_message/add','新增')">
                                  <i class="glyphicon glyphicon-plus"></i>
                              </button>
                              <button type="button" class="btn btn-default" onclick='boMessageConsoleGrid.delete("id","${ctxPath}/console/bo_message/delete");'>
                                  <i class="glyphicon glyphicon-trash"></i>
                              </button>
                 </div>
                     <div class='row'>
                              <div class='col-md-12'>
                                  <table id="boMessage" data-toggle="table"
                                         data-url="${ctxPath}/console/bo_message/json"
                                         data-pagination="true"
                                         data-query-params="boMessageLoadParam"
                                         method="post"
                                         data-side-pagination="server"
                                         data-show-refresh="true"
                                         data-show-toggle="true"
                                         data-pagination-loop="false"
                                         data-show-columns="true"
                                         data-toolbar="#boMessageToolbar">
                                      <thead>
                                      <tr>
                                           <th data-checkbox="true"></th>
                                            <th data-field='id' data-visible='false'>ID</th>
  <th data-field='messageType' data-sortable='true' data-formatter='boMessagemessage_typeFormatter'>消息类型</th>
  <th data-sortable='true' data-field='messageContent'>消息内容</th>
  <th data-sortable='true' data-field='createTime' data-formatter="consoleTableDateFormat" >推送时间</th>
  <th data-sortable='true' data-field='messageTitle'>消息标题</th>
  <th data-field='id' data-formatter='boMessageTableOperate'>操作</th>
 
                                      </tr>
                                      </thead>
                                  </table>
                              </div>
                     </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
     var boMessageConsoleGrid =new consoleGrid({table_id:"boMessage"});
     boMessageConsoleGrid.init();
     function boMessageTableOperate(value){
         var btn =  "<button type='button' class='btn btn-xs btn-default command-edit' onclick='consoleOpenWindow(\"boMessage\",\"${ctxPath}/console/bo_message/edit?id="+value+"\",\"编辑\")'><span class='glyphicon glyphicon-pencil'></span></button> ";
        var btn2  =   "<button type='button' class='btn btn-xs btn-default command-edit' onclick='pushMessage(\""+value+"\")'>推送该消息</button> ";
         return btn+btn2;
     }
     function pushMessage(id) {
         $.confirm({
             title: '提示',
             content: '是否推送该消息？',
             autoClose: 'cancelAction|3000',
             escapeKey: 'cancelAction',
             buttons: {
                 cancelAction: {
                     text: '取消',
                     action: function () {
                     }
                 }, ok: {
                     text: '确定',
                     action: function () {
                         $.post("/console/bo_message/push",{id:id},function () {

                         })
                         $.alert("推送成功!");
                     }
                 }
             }
         });

     }
    function boMessageLoadParam(params){
        params.query=boMessageQueryString();
        return params;
    }
     function boMessageQueryString() {
         var objQuery = new Object();
                objQuery.messageType=$('#messageType').val()==''?null:$('#messageType').val(); 
     objQuery.messageTitle=$('#messageTitle').val()==''?null:$('#messageTitle').val();
 
         var queryString = JSON.stringify(objQuery);
         return queryString;
     }

     function boMessagemessage_typeFormatter(value) 
   { 
       var showValue=''; 
       switch(value+''){
       case '1': 
       showValue = '官方推送';
       break;
       }
    if(showValue.indexOf('不')!=-1||showValue.indexOf('否')!=-1||showValue.indexOf('禁')!=-1){    
       return '<span class="label label-warning">'+showValue+'</span>';
   }else{
       return '<span class="label label-info">'+showValue+'</span>';
   }
   }

 </script>
<%} %>
 